/**
 * by Butnet's Frame Creator
 */
#if class.package
package ${class.package};
#end

#for i in class.imports
import ${.i};
#end

import java.util.List;
import java.util.ArrayList;
import com.butnet.myframe.service.BaseService;
import com.butnet.myframe.hql.query.PageList;

#if class.commet
/**
 * ${class.commet}
 */
#end
public class ${class.name}Service extends BaseService implements I${class.name}Service {
#for f in class.fields
	private ${.f.type} ${.f.name};
#end

	public I${class.name}DAO get${class.name}DAO(){
		return daoFactory.get${class.name}DAO();
	}
#for f in class.fields
	public ${.f.type} ${.f.get}(){
		return this.${.f.name};
	}
	public void ${.f.set}(${.f.type} ${.f.name}){
		this.${.f.name} = ${.f.name};
	}
#end
	public ${class.name} create(${class.name} ${class.fname}){
		try{
			get${class.name}DAO().insert(${class.fname});
			return ${class.fname};
		}catch(Exception e){
			e.printStackTrace(System.err);
			return null;
		}
	}
	public boolean delete(String id){
		try{
			get${class.name}DAO().delete(id);
			return true;
		}catch(Exception e){
			e.printStackTrace(System.err);
			return false;
		}
	}
	public boolean update(${class.name} obj){
		try{
			get${class.name}DAO().update(obj);
			return true;
		}catch(Exception e){
			e.printStackTrace(System.err);
			return false;
		}
	}
	public ${class.name} get(String id){
		return get${class.name}DAO().get(id);
	}
	public List<${class.name}> list(){
		try{
			return get${class.name}DAO().list();
		}catch(Exception e){
			e.printStackTrace(System.err);
			return new ArrayList<${class.name}>(0);
		}
	}
	public List<${class.name}> list(int pageIndex, int pageSize){
		try{
			return get${class.name}DAO().list(pageIndex, pageSize);
		}catch(Exception e){
			e.printStackTrace(System.err);
			return new ArrayList<${class.name}>(0);
		}
	}
	public PageList<${class.name}> pageList(int pageIndex, int pageSize){
		try{
			return get${class.name}DAO().pageList(pageIndex, pageSize);
		}catch(Exception e){
			e.printStackTrace(System.err);
			return new PageList<${class.name}>(-1, new ArrayList<${class.name}>(0));
		}
	}
}